import { getByQuery } from '../../utils/goods'
Page({
  data: {
    value: '',
    datas: []
  },
  onSearch (e) {
    console.log(e.detail, '--搜索---', e.detail.trim())
    if (e.detail.trim()) {
      this.setData({
        value: e.detail
      })
      this.getGood(e.detail)
    }
  },
  onCancel () {
    this.setData({
      datas: []
    })
  },
  async getGood (query) {
    let res = await getByQuery({
      platform: 'mini',
      query
    })
    this.setData({
      datas: res.items
    })
  },
  toDetail (e) {
    wx.navigateTo({
      url: `../retail/retail?id=${e.currentTarget.dataset.item}`
      // url: '../retail/retail'
    })
    // console.log('iiii', e.currentTarget.dataset.item)
  }
})